package com.example.demo.tushare;

import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpUtil;

import java.util.Arrays;
import java.util.Collections;

// token 5c1137e4802bca972d89d5d5ea7ca88c735fc9f49e3881c259c2c9c8
public class TushareApi {
    private String url = "http://api.tushare.pro";

    private String token = "5c1137e4802bca972d89d5d5ea7ca88c735fc9f49e3881c259c2c9c8";

    public void stock_basic() {
        String body = "{\"api_name\": \"stock_basic\", \"token\": \"" + this.token + "\", \"params\": {\"list_stauts\":\"L\"}, \"fields\": \"ts_code,name,area,industry,list_date\"}";
        String resp = HttpUtil.post(this.url, body);

        System.out.println(resp);
    }

    public void stk_premarket() {
        String body = "{\"api_name\": \"stk_premarket\", \"token\": \"" + this.token + "\"}";
        String resp = HttpUtil.post(this.url, body);

        System.out.println(resp);
    }

    // ts_code     trade_date  open  high   low  close  pre_close  change    pct_chg  vol        amount
    public void daily() {
        String body = "{\"api_name\": \"daily\", \"token\": \"" + this.token + "\", \"params\": {\"ts_code\":\"000001.SZ\",\"start_date\":\"20180701\",\"end_date\":\"20180718\"}}";
        String resp = HttpUtil.post(this.url, body);

        System.out.println(resp);
    }
}
